package com.vpen.block.controller;

import com.vpen.block.model.PlanDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @version: 1.0
 * @author: Vpen
 * @date: 2021/11/21 20:13
 * @content:
 */
@Api(tags = "单元测试练习")
@RestController
@RequestMapping("/unit/test")
public class UnitTestController {

    @GetMapping
    @ApiOperation(value = "get请求")
    public String hello() {
        return "hello world";
    }


    @GetMapping("/name")
    @ApiOperation(value = "get请求RequestParam")
    public String hello2(@RequestParam(value = "name") String name) {
        return "hello " + name;
    }

    @GetMapping("/{name}")
    @ApiOperation(value = "get请求PathVariable")
    public String hello3(@PathVariable(value = "name") String name) {
        return "hello " + name;
    }

    @PostMapping("/plan")
    @ApiOperation(value = "Post请求")
    public String hello4(@RequestBody PlanDTO plan) {
        return "hello " + plan;
    }

    @GetMapping("/get/entity")
    @ApiOperation(value = "get请求-实体类")
    public String hello5(PlanDTO plan) {
        return "hello " + plan;
    }

    @PostMapping("/upload")
    @ApiOperation(value = "上传文件")
    public String hello6(@RequestParam(value = "pic")  MultipartFile file) {
        return "hello: " + file;
    }
}

